//
//  LEAnimationButton.m
//  CreditAddressBook
//
//  Created by LE on 15/12/10.
//  Copyright © 2015年 Lee. All rights reserved.
//

#import "LEAnimationButton.h"
#import "POP.h"

@implementation LEAnimationButton

/**
 *  覆盖setHighlighted方法，使按钮没有高亮状态
 *
 *  @param highlighted
 */
- (void)setHighlighted:(BOOL)highlighted {
    if (highlighted) {
        POPBasicAnimation *scaleAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewScaleXY];
        scaleAnimation.duration = 0.1;
        scaleAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.9, 0.9)];
        if (self.imageView) {
//            [self.imageView pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
        }
        if (self.titleLabel) {
//            [self.titleLabel pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
        }
        [self pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
    } else {
        POPSpringAnimation *scaleAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];
        scaleAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(1, 1)];
        scaleAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(2, 2)];
        scaleAnimation.springBounciness = 20.f;
        if (self.imageView) {
//            [self.imageView pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
        }
        if (self.titleLabel) {
//            [self.titleLabel pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
        }
        [self pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
    }
}
@end
